I found this code for the RVI [by Donald Dorsey] provided by TS Support on February 28, 2003:
code:
/ **************************************************
Description: This Indicator plots the Relative Volitility Index
Provided By: TS Support, LLC for eSignal
************************************************** */
function preMain(){
setStudyTitle("Relative Volatility Index");
setCursorLabelName("RVI",0);
setDefaultBarFgColor(Color.red,0);
addBand(30, PS_SOLID, 1, Color.grey);
addBand(70, PS_SOLID, 1, Color.grey);
}
var U_1 = 0;
var D_1 = 0;
var ma = null;
function main(Period){
if(Period == null)
Period = 10;
var StdDev = 0, u = 0, d = 0, U = 0, D = 0, SumSqr = 0;
if(ma == null)
ma = new MAStudy(Period, 0, "Close", MAStudy.SIMPLE);
for(counter = - Period + 1; counter <= 0; counter++)
SumSqr += Math.pow((close(counter) - ma.getValue(MAStudy.MA)),2);
StdDev = Math.sqrt(SumSqr / Period);
if(close() > close(-1)){
u = StdDev;
d = 0
}
else{
d = StdDev;
u = 0;
}
U = (13 * U_1 + u) / 14;
D = (13 * D_1 + d) / 14;
RVI = 100 * U / (U + D);
if (getBarState() == BARSTATE_NEWBAR){
U_1 = U;
D_1 = D;
}
return RVI;
}
This RVI was subsequently refined by Donald Dorsey in an article in the TASC September 1995 issue.
Instead of using the close in the calculation of the RVI Dorsey changed it’s calculation using the highs and the lows. The 1995 Tradestation code is given but since I do not know the TS easy language I am unable to use it for help in converting the new RVI into an efs.
However I have tried modifying the original code from TS Support by using the high and low. The new RVI appears to be plotting on a chart but I am uncertain as to whether my modification has resulted in a correctly working new RVI. I am attaching my modified efs and would be grateful if someone could kindly check if the resultant RVI plot/logic is working correctly. The TS code is also attached.
I have not tried coding the “inertia” section and any help in including it would be very much appreciated too.
Robert
code:
/ **************************************************
Description: This Indicator plots the Relative Volitility Index
Provided By: TS Support, LLC for eSignal
************************************************** */
function preMain(){
setStudyTitle("Relative Volatility Index");
setCursorLabelName("RVI",0);
setDefaultBarFgColor(Color.red,0);
addBand(30, PS_SOLID, 1, Color.grey);
addBand(70, PS_SOLID, 1, Color.grey);
}
var U_1 = 0;
var D_1 = 0;
var ma = null;
function main(Period){
if(Period == null)
Period = 10;
var StdDev = 0, u = 0, d = 0, U = 0, D = 0, SumSqr = 0;
if(ma == null)
ma = new MAStudy(Period, 0, "Close", MAStudy.SIMPLE);
for(counter = - Period + 1; counter <= 0; counter++)
SumSqr += Math.pow((close(counter) - ma.getValue(MAStudy.MA)),2);
StdDev = Math.sqrt(SumSqr / Period);
if(close() > close(-1)){
u = StdDev;
d = 0
}
else{
d = StdDev;
u = 0;
}
U = (13 * U_1 + u) / 14;
D = (13 * D_1 + d) / 14;
RVI = 100 * U / (U + D);
if (getBarState() == BARSTATE_NEWBAR){
U_1 = U;
D_1 = D;
}
return RVI;
}
This RVI was subsequently refined by Donald Dorsey in an article in the TASC September 1995 issue.
Instead of using the close in the calculation of the RVI Dorsey changed it’s calculation using the highs and the lows. The 1995 Tradestation code is given but since I do not know the TS easy language I am unable to use it for help in converting the new RVI into an efs.
However I have tried modifying the original code from TS Support by using the high and low. The new RVI appears to be plotting on a chart but I am uncertain as to whether my modification has resulted in a correctly working new RVI. I am attaching my modified efs and would be grateful if someone could kindly check if the resultant RVI plot/logic is working correctly. The TS code is also attached.
I have not tried coding the “inertia” section and any help in including it would be very much appreciated too.
Robert
Comment